<template>
  <div>
    <el-form :model="ruleForm2" :rules="rules2" ref="ruleForm2" label-position="left" label-width="0px" class="demo-ruleForm login-container">
      <h2 class="title">激活账号</h2>
      <el-form-item prop="number">
        <el-input type="text" v-model="ruleForm2.number" auto-complete="off" placeholder="请输入激活码"></el-input>
      </el-form-item>
      <el-form-item type="text" style="text-align: center">管理员QQ：1905333495</el-form-item>
      <el-form-item style="width:100%;">
        <el-button type="primary" style="width:48%;" @click.native.prevent="handleSubmit2" :loading="logining">激活</el-button>
        <el-button @click.native.prevent="handleReset2">重置</el-button>
      </el-form-item>
    </el-form>
    <el-dialog
        :visible.sync="dialogVisable"
        width="30%">
      <el-form>
        <el-form-item>
          <el-result icon="success" title="激活成功" subTitle="即将跳转至登录页面~">
            <template slot="extra">
              <el-button type="primary" size="medium">确定</el-button>
            </template>
          </el-result>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import { requestLogin } from '../api/api';
//import NProgress from 'nprogress'
export default {
  data() {
    return {
      dialogVisable:false,
      logining: false,
      ruleForm2: {
        number: ''
      },
      rules2: {
        number: [
          { required: true, message: '请输入激活码', trigger: 'blur' },
        ],
      },
    };
  },
  methods: {
    handleReset2() {
      this.$refs.ruleForm2.resetFields();
    },
    handleSubmit2(ev) {
      var _this = this;
      this.$refs.ruleForm2.validate((valid) => {
        if (valid) {
          this.logining = true;
          this.$http.get("/sys/tenant/activateCheck/"+this.ruleForm2.number).then(res => {
            this.logining = false;
            let { message, success} = res.data;
            if (success) {
              this.dialogVisable = true;
              let _time = 3;
              let interval = setInterval(function () {
                if (_time == 0) {
                  _this.$router.push('/');
                  clearInterval(interval)
                }
                _time--;
              }, 1000);
            }else {
              this.$message.error(message);
            }
          });
        } else {
          return false;
        }
      });
    }
  },
  mounted() {

  }
}

</script>

<style lang="scss" scoped>
.login-container {
  /*box-shadow: 0 0px 8px 0 rgba(0, 0, 0, 0.06), 0 1px 0px 0 rgba(0, 0, 0, 0.02);*/
  -webkit-border-radius: 5px;
  border-radius: 5px;
  -moz-border-radius: 5px;
  background-clip: padding-box;
  margin: 180px auto;
  width: 350px;
  padding: 35px 35px 15px 35px;
  background: #fff;
  border: 1px solid #eaeaea;
  box-shadow: 0 0 25px #cac6c6;
  .title {
    margin: 0px auto 40px auto;
    text-align: center;
    color: #505458;
  }
  .remember {
    margin: 0px 0px 35px 0px;
  }
}
</style>